import { User } from "../model/user";
import { Chat } from "../model/chat"
import { hashStr } from "./bcrypt"
import { ListPandaKill } from "../model/listModel/listPandaKill"
import { seq } from "../db"

let users = [
        {
                avatar: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fgss0.baidu.com%2F94o3dSag_xI4khGko9WTAnF6hhy%2Fzhidao%2Fwh%253D450%252C600%2Fsign%3D9f41e6837a310a55c471d6f082756f9f%2Fa71ea8d3fd1f4134ff7d790e261f95cad1c85e73.jpg&refer=http%3A%2F%2Fgss0.baidu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638868959&t=60bb9cc3862fecb41ed1d4fdd980bdaa",
                nickName: "盘古他爹",
                password: hashStr("6673133"),
                userName: "lanshi324",
                role: "boss"
        },
        {
                avatar: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0410%2Fd95f77acj00q8kmcz001ad200dw00dwg00660066.jpg&refer=http%3A%2F%2Fdingyue.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638868988&t=72fbd8fb92f6c37a2b9a1b1d4dac8b62",
                nickName: "保安队长",
                password: hashStr("123456"),
                userName: "leader",
                role: "leader"
        },
        {
                avatar: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.crcz.com%2Fallimg%2F201911%2F20%2F1574263566811364.jpg&refer=http%3A%2F%2Fimg.crcz.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638869021&t=8fbf426763b349b1dc371e782c688d0e",
                nickName: "小瓜皮",
                password: hashStr("123456"),
                userName: "farmer",
                role: "farmer"
        }
]

let listOne = {
        name: "JY",
        label: "没脖子,狼王,歪三刀",
        avatar: "",
        trends: "二胎都上学了,虎牙狼人杀11月份扬帆起航",
        video_thumbnail: ""
}

const LikePandaKillData = [
        {
                name: "JY01",
                label: "球形闪电",
                avatar: "",
                trends: "我是没脖子",
                video_thumbnail: ""
        },
        {
                name: "09",
                label: "创世神，大酒神",
                avatar: "",
                trends: "先有09后有天",
                video_thumbnail: ""
        },
        {
                name: "09",
                label: "我们都爱大酒神",
                avatar: "",
                trends: "伍声只爱冷雨萱",
                video_thumbnail: ""
        },
        {
                name: "囚徒",
                label: "囚大，拳王",
                avatar: "",
                trends: "五花马千金囚，狂野乱斗一轮游!",
                video_thumbnail: ""
        },
        {
                name: "囚徒",
                label: "囚日天",
                avatar: "",
                trends: "再上四个我就是狗!",
                video_thumbnail: ""
        }
]

const chats = [
        {
                userId: 1,
                friend: 2,
                content: JSON.stringify([{
                        time: "2021-09-10 12:10:10",
                        my: "你在干啥"
                },
                {
                        time: "2021-09-10 12:30:10",
                        he: "我在打dota"
                }
                ])
        },
        {
                userId: 1,
                friend: 3,
                content: JSON.stringify([{
                        time: "2021-09-10 12:10:10",
                        word: "处对象啊"
                }])
        },
        {
                userId: 2,
                friend: 3,
                content: JSON.stringify([{
                        time: "2021-09-10 12:10:10",
                        word: "我是2我跟3是好朋友"
                }])
        }
]




async function init() {

        try {
                // await seq.authenticate();
                console.log('连接成功111');
                //重建所有表
                await seq.sync({ force: true });
                console.log(2222);

                //插入一条用户数据
                // await  User.create(user)
                //批量插入初始用户
                await User.bulkCreate(users)

                //插入列表1的数据
                await ListPandaKill.create(listOne)
                await seq.authenticate();
                //批量添加列表1的数据
                await ListPandaKill.bulkCreate(LikePandaKillData)

                //批量插入聊天表数据
                await Chat.bulkCreate(chats)
                console.log('Connection has been established successfully.');
                seq.close()
        } catch (error) {
                console.error('Unable to connect to the database:', error);
        }
}

init()